﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;
using System.Data;

namespace PeisongWeb.buyer
{
    public partial class buyer_dynamicOrderList : buyerPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (hasPermission("BB", 1))
                {
                    if (allowAccess(Convert.ToInt32(companyType.Buyer)))
                    {
                        rptBind();
                    }
                    else
                    {
                        Library.Script.ClientUrl("buyer_index.html");
                        return;
                    }
                }
                else
                {
                    Library.Script.ClientMsgUrl("没有权限！", "buyer_index.html");
                    return;
                }
            }
        }
        void rptBind()
        {
            StringBuilder where = new StringBuilder();
            where.AppendFormat("1=1 and companyId={0}",logic.customer.companyId);
            if (ext_startReceiveDt.SelectedDate != DateTime.MinValue)
                where.AppendFormat(" AND convert(nvarchar(10),receiveDt,121)='{0}'", ext_startReceiveDt.SelectedDate.ToShortDateString());

            DataSet ds = logic.order.selectDynamicOrder(where.ToString(), "orderid desc", AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex);
            AspNetPager1.RecordCount = Convert.ToInt32(ds.Tables[0].Rows[0][0]);
            rpt_list.DataSource = ds.Tables[1];
            rpt_list.DataBind();
        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            rptBind();
        }

        protected void btn_select_Click(object sender, EventArgs e)
        {
            rptBind();
        }
    }
}
